/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package betportal.impl;

import betportal.BetportalPackage;
import betportal.Component;
import betportal.DataTypeContainer;
import betportal.Portal;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Portal</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link betportal.impl.PortalImpl#getComponents <em>Components</em>}</li>
 *   <li>{@link betportal.impl.PortalImpl#getDataTypeContainer <em>Data Type Container</em>}</li>
 *   <li>{@link betportal.impl.PortalImpl#getEntityPackage <em>Entity Package</em>}</li>
 *   <li>{@link betportal.impl.PortalImpl#getBusinessPackage <em>Business Package</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PortalImpl extends PortalElementImpl implements Portal {
	/**
	 * The cached value of the '{@link #getComponents() <em>Components</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponents()
	 * @generated
	 * @ordered
	 */
	protected EList<Component> components;

	/**
	 * The cached value of the '{@link #getDataTypeContainer() <em>Data Type Container</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataTypeContainer()
	 * @generated
	 * @ordered
	 */
	protected DataTypeContainer dataTypeContainer;

	/**
	 * The default value of the '{@link #getEntityPackage() <em>Entity Package</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEntityPackage()
	 * @generated
	 * @ordered
	 */
	protected static final String ENTITY_PACKAGE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getEntityPackage() <em>Entity Package</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEntityPackage()
	 * @generated
	 * @ordered
	 */
	protected String entityPackage = ENTITY_PACKAGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getBusinessPackage() <em>Business Package</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusinessPackage()
	 * @generated
	 * @ordered
	 */
	protected static final String BUSINESS_PACKAGE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getBusinessPackage() <em>Business Package</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusinessPackage()
	 * @generated
	 * @ordered
	 */
	protected String businessPackage = BUSINESS_PACKAGE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PortalImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BetportalPackage.Literals.PORTAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Component> getComponents() {
		if (components == null) {
			components = new EObjectContainmentEList<Component>(Component.class, this, BetportalPackage.PORTAL__COMPONENTS);
		}
		return components;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataTypeContainer getDataTypeContainer() {
		return dataTypeContainer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDataTypeContainer(DataTypeContainer newDataTypeContainer, NotificationChain msgs) {
		DataTypeContainer oldDataTypeContainer = dataTypeContainer;
		dataTypeContainer = newDataTypeContainer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BetportalPackage.PORTAL__DATA_TYPE_CONTAINER, oldDataTypeContainer, newDataTypeContainer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDataTypeContainer(DataTypeContainer newDataTypeContainer) {
		if (newDataTypeContainer != dataTypeContainer) {
			NotificationChain msgs = null;
			if (dataTypeContainer != null)
				msgs = ((InternalEObject)dataTypeContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - BetportalPackage.PORTAL__DATA_TYPE_CONTAINER, null, msgs);
			if (newDataTypeContainer != null)
				msgs = ((InternalEObject)newDataTypeContainer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - BetportalPackage.PORTAL__DATA_TYPE_CONTAINER, null, msgs);
			msgs = basicSetDataTypeContainer(newDataTypeContainer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BetportalPackage.PORTAL__DATA_TYPE_CONTAINER, newDataTypeContainer, newDataTypeContainer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getEntityPackage() {
		return entityPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEntityPackage(String newEntityPackage) {
		String oldEntityPackage = entityPackage;
		entityPackage = newEntityPackage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BetportalPackage.PORTAL__ENTITY_PACKAGE, oldEntityPackage, entityPackage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getBusinessPackage() {
		return businessPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBusinessPackage(String newBusinessPackage) {
		String oldBusinessPackage = businessPackage;
		businessPackage = newBusinessPackage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BetportalPackage.PORTAL__BUSINESS_PACKAGE, oldBusinessPackage, businessPackage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case BetportalPackage.PORTAL__COMPONENTS:
				return ((InternalEList<?>)getComponents()).basicRemove(otherEnd, msgs);
			case BetportalPackage.PORTAL__DATA_TYPE_CONTAINER:
				return basicSetDataTypeContainer(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BetportalPackage.PORTAL__COMPONENTS:
				return getComponents();
			case BetportalPackage.PORTAL__DATA_TYPE_CONTAINER:
				return getDataTypeContainer();
			case BetportalPackage.PORTAL__ENTITY_PACKAGE:
				return getEntityPackage();
			case BetportalPackage.PORTAL__BUSINESS_PACKAGE:
				return getBusinessPackage();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BetportalPackage.PORTAL__COMPONENTS:
				getComponents().clear();
				getComponents().addAll((Collection<? extends Component>)newValue);
				return;
			case BetportalPackage.PORTAL__DATA_TYPE_CONTAINER:
				setDataTypeContainer((DataTypeContainer)newValue);
				return;
			case BetportalPackage.PORTAL__ENTITY_PACKAGE:
				setEntityPackage((String)newValue);
				return;
			case BetportalPackage.PORTAL__BUSINESS_PACKAGE:
				setBusinessPackage((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BetportalPackage.PORTAL__COMPONENTS:
				getComponents().clear();
				return;
			case BetportalPackage.PORTAL__DATA_TYPE_CONTAINER:
				setDataTypeContainer((DataTypeContainer)null);
				return;
			case BetportalPackage.PORTAL__ENTITY_PACKAGE:
				setEntityPackage(ENTITY_PACKAGE_EDEFAULT);
				return;
			case BetportalPackage.PORTAL__BUSINESS_PACKAGE:
				setBusinessPackage(BUSINESS_PACKAGE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BetportalPackage.PORTAL__COMPONENTS:
				return components != null && !components.isEmpty();
			case BetportalPackage.PORTAL__DATA_TYPE_CONTAINER:
				return dataTypeContainer != null;
			case BetportalPackage.PORTAL__ENTITY_PACKAGE:
				return ENTITY_PACKAGE_EDEFAULT == null ? entityPackage != null : !ENTITY_PACKAGE_EDEFAULT.equals(entityPackage);
			case BetportalPackage.PORTAL__BUSINESS_PACKAGE:
				return BUSINESS_PACKAGE_EDEFAULT == null ? businessPackage != null : !BUSINESS_PACKAGE_EDEFAULT.equals(businessPackage);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (entityPackage: ");
		result.append(entityPackage);
		result.append(", businessPackage: ");
		result.append(businessPackage);
		result.append(')');
		return result.toString();
	}

} //PortalImpl
